﻿package mortal.game.view.autoArena.view
{
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class AutoArenaIcon extends ActionBaseIcon
    {
        protected var _leftTime:SecTimerView;
        private static var _instance:AutoArenaIcon;

        public function AutoArenaIcon()
        {
            super(ResFileConst.AutoArenaIcon);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._leftTime = UIFactory.secTimeView("mm:ss", 5 - 8, 50, 60, 20, this, GlobalStyle.textFormatHong.center());
            this._leftTime.timeOutHandler = this.timeCompl;
            return;
        }// end function

        public function timeCompl() : void
        {
            this._leftTime.stop();
            this._leftTime.visible = false;
            return;
        }// end function

        public function updateLeftTime(param1:int, param2:String) : void
        {
            if (param1 > 0)
            {
                this._leftTime.visible = true;
                this._leftTime.setParse(param2);
                this._leftTime.setLeftTime(param1);
            }
            return;
        }// end function

        override protected function timeOutCaller() : void
        {
            this.setLeftTimeAndState(0, 1);
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            if (GameController.autoArena.view.isHide)
            {
                GameController.autoArena.view.show();
            }
            else
            {
                GameController.autoArena.view.hide();
            }
            return;
        }// end function

        public function setStateImagePos() : void
        {
            _countDownTime.stateImageXPos = 35.5 - 25;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._leftTime.dispose();
            this._leftTime = null;
            return;
        }// end function

        public static function get instance() : AutoArenaIcon
        {
            if (!_instance)
            {
                _instance = new AutoArenaIcon;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
